﻿using AwesomeChromeFormUI.Attributes;
using AwesomeChromeFormUI.Configs;
using AwesomeChromeFormUI.Reflections;
using System;
using System.Reflection;

namespace AwesomeChromeFormUI.Interfaces.Configs
{
    /// <summary>
    /// 默认接口实现
    /// </summary>
    public class DefaultIMainViewConfiger
    {
        public static MainViewConfiguration CreateCustomMainViewConfiguration()
        {
            Type type = AttributeUtil.FindFirstAnnotatedClass<MainViewConfigurationAttribute, IMainViewConfiger>();

            if (type != null)
            {

                ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);

                if (constructor != null)
                {
                    IMainViewConfiger baseFormConfiger = constructor.Invoke(null) as IMainViewConfiger;
                    return baseFormConfiger.CreateCustomBaseFormConfiguration();
                }
            }

            return new MainViewConfiguration();
        }
    }
}
